import 'package:flutter/services.dart';
import 'package:flutter_elf/utils/print_utils.dart';

class GoToStoreUtils{

  static const String _GoToMarket = 'goToMarket';
  static const String _GoToMarketQQ = 'goToMarketQQ';
  static const String _GetInstallAppMarkets = 'getInstallAppMarkets';
  static const String _QueryInstalledMarketPkgs = 'queryInstalledMarketPkgs';
  static const MethodChannel _channel =
  MethodChannel('com.flutter.plugins/tostore');
  Future<void> registerApp() async {
    _channel.setMethodCallHandler(_handleMethod);
  }

  static goToMarket(){
    _channel.invokeMethod(_GoToMarket);
  }
  static Future<List>getInstallAppMarkets()async{
    List l = await _channel.invokeListMethod(_GetInstallAppMarkets);
    globalPrint(l.toString());
    return (await _channel.invokeMethod(_GetInstallAppMarkets)) as List;
  }
  static queryInstalledMarketPkgs()async{
    return (await _channel.invokeMethod(_QueryInstalledMarketPkgs)) as List;
  }
  Future<dynamic> _handleMethod(MethodCall call) async {
    switch (call.method) {
      case _GoToMarket:
        _channel.invokeMethod(_GoToMarket);
        break;
    }
  }

}